import React from 'react';
import { ts2Formatter,renderState,renderEnable } from 'utils';
import moment from 'moment';
import { actions } from 'mirrorx';
{/*
可配置化种类：

1、表格头部字段 
    1、列表页表格头部字段集合 mainTableColumn
    2、编辑页表格头部字段集合 childTableColumn

2、编辑框的字段
    1、编辑页 直接显示在页面的编辑字段 FormField
    2、编辑页 需要点击表格的增行弹框编辑的字段 FormTableField
    3. 列表页查询区域  searchField

3.表头部的按钮  headerButtonSets

4.表行尾部按钮  columnButtonSets
*/}

//表头信息

//字段属性

//基本信息
const FormDataHeader = [
    {
        enname: "billcode",
        zhname: "报销单号",
        pattern:/^\S*$/,
        message: "不能有空格",
        type: "FormControl",
        hidepage:{0:true},
        edit: false,
    },
    {
        enname: "organizationId",
        codename: "organizationCode",
        showname: "organizationName",
        zhname: "隶属组织",
        type: "RefComponent",
        requirecontrol:[{
            value: "0001A110000000001TUK,0001A110000000001S6Z",
            refKey: "refpk",
            dtoKey: "organizationId",
            layer: ["FormField", "DataHeader", "Field"],
            fields: ["approvalId"]
            },
        ],
        cascadeName: [{
            paramkey: "EQ_customerAreas.organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "customerId",
            resetOffersFlag: true,
        },{
            paramkey: "EQ_customerAreas.organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "payCustomerId",
            resetOffersFlag: true,
        },{
            paramkey: "EQ_organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "marketareaId",
            resetOffersFlag: true,
        },{
            paramkey: "EQ_organization.id",
            childtype: "expenseSon",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "cpaydeptidId",
            resetOffersFlag: true,
        },{
            paramkey: "EQ_personPosts.organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "dutyPersonId",
            resetOffersFlag: true,
        },{
            paramkey: "EQ_personPosts.organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "payPersonId",
            resetOffersFlag: true,
        },
        {
            paramkey: "EQ_organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "shopId",
            resetOffersFlag: true,
        },{
            paramkey: "EQ_financeOrganization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "bankaccountId",
            resetOffersFlag: true,
        },
        {
            paramkey: "EQ_supplierFinances.organization.id",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "paySupplerId",
            resetOffersFlag: true,
        },
        {
            paramkey: "EQ_organization",
            childtype: "DataHeader",
            refKey: "refpk",
            dtoKey: "organizationId",
            offers: "approvalId",
            resetOffersFlag: true,
        }
    ],
        param:{
            "AUTH_refdim": "organization", 
            "AUTH_refcod": "ExpenseClaim"
        },
        cascadeChildTable:[{
            refKey: "refpk", 
            dtoKey: "organizationId",
            childType:"expenseSon" 
        },{
            refKey: "refpk", 
            dtoKey: "organizationId",
            childType:"expenseSon"
        },{
            refKey: "refpk", 
            dtoKey: "organizationId",
            childType:"expenseSon"
        }],
        refname:"organization",
        edit: true,
        required: true,
    },
    {
        enname: "approvalId",
        codename: "approvalCode",
        showname: "approvalName",
        zhname: "审批管理",
        refname: "approvalDocBXSP001",
        alias:"organizationId",
        type: "RefComponent",
        edit: true,
        required: false,
    },
    {
        enname: "billDate",
        zhname: "单据日期",
        edit: true,
        defaultValue:moment(),
        format:"YYYY-MM-DD",
        type: "DatePicker",
    },
    {
        enname:"marketareaId",
        codename:"marketareaCode",
        showname:"marketareaName",
        alias:"organizationId",
        zhname:"部门片区",
        param:{
            "AUTH_refdim": "marketarea", 
            "AUTH_refcod": "ExpenseClaim",
            "EQ_enableState":"0",
        },
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "cpaydeptidId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "cpaydeptidCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "cpaydeptidName",
            childType:"expenseSon"
        }],
        required: true,
        edit:true,
        refname:"departmentRef",
        type: "RefComponent",
    },
    {
        enname:"ext11Name",
        zhname:"部门地区",
        required: false,
        hidepage:{0:true,1:true,2:false},
        type: "FormControl",
        edit: false
    },
    {
        enname:"ext12Name",
        zhname:"部门大区",
        required: false,
        hidepage:{0:true,1:true,2:false},
        type: "FormControl",
        edit: false
    },
    {
        enname: "billtypeId",
        showname: "billtypeName",
        codename: "billtypeCode",
        zhname: "单据类型",
        type: "Select",
        code:"FA001",
        edit: true,
        cascadeName: {
            paramkey: "ZHEN_code",
            childtype: "DataHeader",
            refKey: "refcode",
            dtoKey: "billtypeCode",
            offers: "settlementId",
            resetOffersFlag: true,
        },
        required:true,
    },
    {
        enname: "feeitemId",
        codename: "feeitemCode",
        showname: "feeitemName",
        zhname: "费用业务类型",
        refname:"feeType",
        param:{"EQ_enableState": "1","ZHEN_code":"11","EQ_isEnable":"1"},
        type: "RefComponent",
        cascadeChildTable:[{
            refKey: "refcode", 
            dtoKey: "headFeeItemShadowCode",
            childType:"expenseSon" 
        },{
            refKey: "aa", 
            dtoKey: "feeitemId",
            childType:"expenseSon" 
        },{
            refKey: "aa", 
            dtoKey: "feeitemCode",
            childType:"expenseSon" 
        },{
            refKey: "aa", 
            dtoKey: "feeitemName",
            childType:"expenseSon" 
        }],
        requirecontrol:[
        {
            value: "1001A11000000001N43Q",
            refKey: "refpk",
            dtoKey: "feeitemId",
            layer: ["FormField", "DataHeader", "Field"],
            fields: ["shopId"]
        },
        {
            value: "1001A11000000001N43Q",
            refKey: "refpk",
            dtoKey: "feeitemId",
            layer: ["childTableColumn", "expenseSon", "column"],
            fields: ["shopName"]
        }
    ],
        treeNodeDisabledKey:'disabledKey',
        edit: false,
        required:true,
    },
    {
        enname: "feeBusiTypeId",
        codename: "feeBusiTypeCode",
        showname: "feeBusiTypeName",
        zhname: "交易对象类型",
        edit: true,
        code:"FA002",
        showcontrol:[
            {
                value: "0,1",
                refKey: "code",
                dtoKey: "feeBusiTypeCode",
                layer: ["FormField", "DataHeader", "Field"],
                fields: ["ext09Id","ext10"]
            },
            {
                value: "0",
                refKey: "code",
                dtoKey: "feeBusiTypeCode",
                layer: ["FormField", "DataHeader", "Field"],
                fields: ["payCustomerId"]
            },
            {
                value: "1",
                refKey: "code",
                dtoKey: "feeBusiTypeCode",
                layer: ["FormField", "DataHeader", "Field"],
                fields: ["paySupplerId"]
            },
            {
                value: "3",
                refKey: "code",
                dtoKey: "feeBusiTypeCode",
                layer: ["FormField", "DataHeader", "Field"],
                fields: ["payPersonId"]
            },
        ],
        requirecontrol:[
            {
                value: "0",
                refKey: "code",
                dtoKey: "feeBusiTypeCode",
                layer: ["FormField", "DataHeader", "Field"],
                fields: ["customerId"]
            }
        ],
        type: "Select",
        required: true,
    },
    {
        enname: "payCustomerId",
        codename: "payCustomerCode",
        showname: "payCustomerName",
        zhname: "支付客户",
        edit: true,
        required:true,
        alias:"organizationId",
        param:{"EQ_isFrozen": "0"},
        type: "RefComponent",
        refname: "terminalcustomerRef",
    },
    {
        enname: "paySupplerId",
        codename: "paySupplerCode",
        showname: "paySupplerName",
        zhname: "支付供应商",
        alias:"organizationId",
        edit: true,
        required:true,
        type: "RefComponent",
        refname: "supplierRef",
    },
    {
        enname: "payPersonId",
        codename: "payPersonCode",
        showname: "payPersonName",
        zhname: "支付个人",
        alias:"organizationId",
        edit: true,
        required:true,
        type: "RefComponent",
        refname: "terminalPersonRef",
    },
    {
        enname: "customerId",
        showname: "customerName",
        codename: "customerCode",
        zhname: "客户",
        edit: false,
        alias:"organizationId",
        param:{
            "AUTH_refdim": "customer", 
            "AUTH_refcod": "ExpenseClaim",
            "EQ_isFrozen": "0"
        },
        relation: [
            {
                ref: "dutyPersonId",
                refpk: "businessId",
                refcode: "businessCode",
                refname: "businessName",
                relationType: "ref",
        },{
            ref: "custchantypeId",
            refpk: "custChanTypeId",
            refcode: "custChanTypeCode",
            refname: "custChanTypeName",
            relationType: "ref",
        }],
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "customerId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "customerCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "customerName",
            childType:"expenseSon"
        },{
            refKey: "businessId",
            dtoKey: "dutyPersonId",
            childType:"expenseSon"
        },
        {
            refKey: "businessCode",
            dtoKey: "dutyPersonCode",
            childType:"expenseSon"
        },
        {
            refKey: "businessName",
            dtoKey: "dutyPersonName",
            childType:"expenseSon"
        },{
            refKey: "custChanTypeId",
            dtoKey: "custchantypeId",
            childType:"expenseSon"
        },
        {
            refKey: "custChanTypeCode",
            dtoKey: "custchantypeCode",
            childType:"expenseSon"
        },
        {
            refKey: "custChanTypeName",
            dtoKey: "custchantypeName",
            childType:"expenseSon"
        }],
        type: "RefComponent",
        refname: "terminalcustomerRef",
    },
    {
        enname: "dutyPersonId",
        showname: "dutyPersonName",
        codename: "dutyPersonCode",
        zhname: "责任业务",
        edit: true,
        required:true,
        alias: "organizationId",
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "dutyPersonId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "dutyPersonCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "dutyPersonName",
            childType:"expenseSon"
        }],
        type: "RefComponent",
        refname: "terminalPersonRef",
    },
    {
        enname: "custchantypeId",
        codename: "custchantypeCode",
        showname: "custchantypeName",
        zhname: "客户渠道",
        edit: false,
        param:{
            "AUTH_refdim": "custchantype", 
            "AUTH_refcod": "ExpenseClaim",
            "EQ_enableState": "1",
        },
        required:true,
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "custchantypeId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "custchantypeCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "custchantypeName",
            childType:"expenseSon"
        }],
        type: "RefComponent",
        refname: "custchantype",
    },
    {
        enname: "commoditybrandId",
        codename: "commoditybrandCode",
        showname: "commoditybrandName",
        zhname: "商品品牌",
        param:{
            "AUTH_refdim": "commoditybrand", 
            "AUTH_refcod": "ExpenseClaim"
        },
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "commoditybrandId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "commoditybrandCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "commoditybrandName",
            childType:"expenseSon"
        }],
        edit: true,
        type: "RefComponent",
        refname: "brandref",
        required: true,
    },
    {
        enname: "goodscategoryId",
        codename: "goodscategoryCode",
        showname: "goodscategoryName",
        zhname: "商品品类",
        param:{
            "EQ_enableState": "0"
        },
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "goodscategoryId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "goodscategoryCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "goodscategoryName",
            childType:"expenseSon"
        }],
        edit: true,
        type: "RefComponent",
        refname: "terminalGoodsCate",
        required: true,
    },
    {
        enname: "shopId",
        codename: "shopCode",
        showname: "shopName",
        zhname: "门店",
        edit: true,
        alias:"organizationId",
        cascadeChildTable:[{
            refKey: "refpk",
            dtoKey: "shopId",
            childType:"expenseSon"
        },
        {
            refKey: "refcode",
            dtoKey: "shopCode",
            childType:"expenseSon"
        },
        {
            refKey: "refname",
            dtoKey: "shopName",
            childType:"expenseSon"
        }],
        type: "RefComponent",
        refname: "terminal",
    },
    {
        enname: "billStatusId",
        codename: "billStatusCode",
        showname: "billStatusName",
        zhname: "审批状态",
        type: "Select",
        hidepage: { 0: true },
        code: "BILL_STATUS",
        required: false,
        edit: false,
    },
    {
        enname: "settlementId",
        codename: "settlementCode",
        showname: "settlementName",
        zhname: "支付方式",
        alias:"billtypeId",
        type: "RefComponent",
        refname: "settlementRef",
        requirecontrol: [{
            value: "1001A11000000001N4AX,0001Z0100000000000Y3,1001A11000000003VWXG",
            refKey: "refpk",
            dtoKey: "settlementId",
            layer: ["childTableColumn", "expenseSon", "column"],
            fields: ["memo"]
        },{
            value: "0001Z0100000000000Y3",
            refKey: "refpk",
            dtoKey: "settlementId",
            layer: ["childTableColumn", "expenseSon", "column"],
            fields: ["feeremark"]
        },{
            value: "0001Z0100000000000Y3",
            refKey: "refpk",
            dtoKey: "settlementId",
            layer: ["FormField", "DataHeader", "Field"],
            fields: ["bankaccountId"]
        }
    ],
        edit: true,
        required:true,
    },
    {
        enname: "bankaccountId",
        codename: "bankaccountAccountNumber",
        showname: "bankaccountAccountName",
        zhname: "出款银行",
        refname:"bankofcompanyRef",
        type: "RefComponent",
        edit: true,
        alias:"organizationId",
    },
    {
        enname: "custbillcode",
        zhname: "客户单号",
        type: "FormControl",
        pattern:/^\S*$/,
        message: "不能有空格",
        edit: true,
        required: false,
    },
    {
        enname: "voucher",
        zhname: "凭证号",
        type: "FormControl",
        pattern:/^\S*$/,
        message: "不能有空格",
        edit: true,
    },
    {
        enname: "ext09Id",
        codename: "ext09Code",
        showname: "ext09Name",
        zhname: "收款银行",
        edit: false,
        type: "RefComponent",
        refname: "bankRef",
    },
    {
        enname: "ext10",
        zhname: "收款账号",
        edit: false,
        type: "FormControl",
    },
    {
        enname: "expenseamount",
        zhname: "报销金额",
        edit: false,
        type: "InputNumber",
    },
    {
        enname: "ext01",
        zhname: "单据来源",
        type: "FormControl",
        hidepage: { 0: true},
        edit: false,
    },
    {
        enname: "ext02",
        zhname: "来源单据号",
        type: "FormControl",
        hidepage: { 0: true},
        edit: false,
    },
    {
        enname: "remark",
        zhname: "摘要",
        type: "FormControl",
        componentClass: "textarea",
        message: "不能有空格",
        pattern:/^\S*$/,
        edit: true,
    },
    {
        enname: "signReceive",
        zhname: "标记签收",
        edit: true,
        type: "Radio",
        hidepage:{0:true,1:true,2:false},
        options: [{
            "key": 1,
            "value": "是"
        },
        {
            "key": 0,
            "value": "否"
        }],
    },
    {
        enname: "initialStage",
        zhname: "期初标识",
        edit: false,
        type: "Radio",
        // hidepage:{0:true,1:false,2:false},
        options: [{
            "key": 1,
            "value": "是"
        },
        {
            "key": 0,
            "value": "否"
        }],
    },
    {
        enname: "marrkId",
        codename: "marrkCode",
        showname: "marrkName",
        zhname: "制单人",
        param:{
            "AUTH_refdim": "marrk", 
            "AUTH_refcod": "ExpenseClaim"
        },
        type: "RefComponent",
        refname: "personRef",
        hidepage:{0:true},
        edit: false,
    },
    {
        enname: "marrkdate",
        zhname: "制单日期",
        type: "DatePicker",
        format:"YYYY-MM-DD",
        hidepage: { 0: true },
        edit: true,
        required: false,
    },
    {
        enname:"approveTime",
        zhname:"审核日期",
        required: false,
        hidepage:{0:true,1:false,2:false},
        type: "DatePicker",
        format:"YYYY-MM-DD",
        edit: false
    },
    {
        enname: "redbillcode",
        zhname: "红冲单据号",
        type: "FormControl",
        hidepage:{0:true},
        edit: false,
    },
    {
        enname: "ext03Id",
        showname: "ext03Name",
        codename: "ext03Code",
        zhname: "协同组织",
        type: "RefComponent",
        refname: "organization",
        hidepage: { 0: true, 1: true},
        edit: false,
    },
];

const columnexpenseAttachmentDtos = [
    {
        title: "标题",
        dataIndex: "filename",
        key: "filename",
        detailwidth: 250,
    }, {
        title: "上传时间",
        dataIndex: "creationTime",
        key: "creationTime",
        detailwidth: 150,
        render: (text, record, index) => {
            return text && ts2Formatter(text,1);
        }
    }, {
        title: "缩略图",
        dataIndex: "fileUrl",
        key: "fileUrl",
        width: 150,
        render: (text, record, index) => {
            if(record.fileUrl.search("jpg") != -1 || record.fileUrl.search("jpeg") != -1 ||record.fileUrl.search("png") != -1){
                return <span>
                <img style={{"width":"35px"}} src={text} />
             </span>
            }else {
                return ""
            }
            
        }
    }, 
    {
        title: "创建人",
        dataIndex: "creator",
        key: "creator",
        width: 150,
    },
    {
        title: "发票号",
        dataIndex: "ext01",
        key: "ext01",
        width: 150,
    }, 
    {
        title: "发票金额",
        dataIndex: "ext03",
        key: "ext03",
        width: 150,
    }, 
    {
        title: "验证结果",
        dataIndex: "ext02",
        key: "ext02",
        width: 150,
    },
    {
        title: "验票说明",
        dataIndex: "ext04",
        key: "ext04",
        width: 150,
    }, 
]

const columnexpenseSon = [
    {
        title: "费用业务科目",
        dataIndex: "feeitemName",
        key:"feeitemId",
        // renderType: "refcomponent",
        width: 150,
        validate: false,
        required:true,
        fixed:"left",
        filedProps: {
            childType: "retailOrderItems",
            title: "费用业务科目",
            refName: "feeType",
            treeNodeDisabledKey:'disabledKey',
            constparam:{
                "EQ_enableState": "1",
                "ZHEN_below":"3",
                "EQ_isEnable":"1"
            },
            aliasparam: [{
                paramkey: "ZHEN_code",
                alias: "headFeeItemShadowCode",
            }],
            fieldName: "feeitemName",
            reffields: { refpk: "feeitemId", refname: "feeitemName", refcode: "feeitemCode" }
        },
    },
    {
        title: "收支项目（财务）",
        dataIndex: "feeprojectName",
        key:"feeprojectId",
        renderType: "refcomponent",
        width: 150,
        validate: false,
        required:true,
        fixed:"left",
        filedProps: {
            childType: "retailOrderItems",
            title: "收支项目（财务）",
            constparam:{
                "EQ_isEnable":"1",
            },
            refName: "feeType",
            cfgParam: { "ctx":"/uitemplate_web","refType":"RefTreeInput","EQ_enableState": "1"},
            fieldName: "feeprojectName",
            reffields: { refpk: "feeprojectId", refname: "feeprojectName", refcode: "feeprojectCode" }
        },
    },
    {
        dataIndex: "month",
        title: "发生月份",
        key:"month",
        renderType: "datepicker",
        width:100,
        validate:false,
        required:true,
        fixed:"left",
        render: (text, record, index) => {
            return new Date(text).getFullYear()+'-'+(new Date(text).getMonth()+1);
        },
        filedProps: {
            format:"YYYY-MM",
        }
    },
    {
        title: "费用说明",
        dataIndex: "feeremark",
        key:"feeremark",
        renderType: "input",
        pattern:/^\S*$/,
        patternMessage: "不能有空格",
        width: 150,
        fixed:"left",
        validate: false,
        filedProps: {
            defaultValue: "",
            maxLength: '200'
        }
    },
    {
        dataIndex: "confirmbillcode",
        key: "confirmbillcode",
        title: "确认号",
        pattern:/^\S*$/,
        patternMessage: "不能有空格",
        edit: true,
        fixed:"left",
        filedProps: {
            maxLength: '20'
        },
        render:(text,record) => {
            return <a 
                value="ExpenseConfirmation" 
                name="费用确认单"
                onClick = {(e)=>{
                    e.preventDefault();//阻止默认事件
                    window.top.handleClick(e,1);//调用打开新页签方法
                }}
                href={encodeURIComponent(encodeURIComponent(`/fmcg-web-react/OrderFish#/ExpenseConfirmation-edit?search_id=${record.sourceHeadPk}&btnPageFlag=${2}`))} >
                {text}
            </a>
        }
    },
    {
        dataIndex: "expenseamount",
        key: "expenseamount",
        title: "报销金额",
        width:150,
        validate:false,
        required:true,
        renderType: "inputnumber",
        filedProps: {
            precision:2,
            except:0,
            // min: 0,
        }
    },
    {
        dataIndex: "availableexpenseamount",
        key: "availableexpenseamount",
        title: "可报销金额",
        width:100,
    },
    {
        title: "税率%",
        dataIndex: "taxNum",
        key:"taxNum",
        width: 90,
        validate:false,
        required:true,
        renderType:"inputnumber",
        filedProps: {
            precision:2,
            min: 0,
        },
    },
    {
        dataIndex: "taxamount",
        key: "taxamount",
        title: "税额",
        width:100,
        renderType: "inputnumber",
        filedProps: {
            precision:2,
            min: 0,
        }
    },
    {
        dataIndex: "shopName",
        key: "shopId",
        title: "门店名",
        renderType: "refcomponent",
        width: 150,
        filedProps: {
            title: "门店名",
            aliasparam: [{
                paramkey: "EQ_organization.id",
                alias: "organizationId",
            }],
            refName: "terminal",
            fieldName: "shopName",
            reffields: { refpk: "shopId", refname: "shopName", refcode: "shopCode" }
        },
    },
    {
        dataIndex: "memo",
        key: "memo",
        title: "发票号",
        renderType: "input",
        pattern:/^\S*$/,
        patternMessage: "不能有空格",
        edit: true,
        filedProps: {
            defaultValue: "",
            maxLength: '200'
        },
        required: false,
    },
    {
        title: "费用承担部门",
        dataIndex: "cpaydeptidName",
        key:"cpaydeptidId",
        renderType: "refcomponent",
        width: 100,
        validate: false,
        required:true,
        filedProps: {
            title: "费用承担部门",
            refName: "departmentRef",
            fieldName: "cpaydeptidName",
            childType: "DataHeader",
            // multiple:true,
            aliasparam: [{
                paramkey: "EQ_organization.id",
                alias: "organizationId",
            }],
            constparam:{
                "EQ_enableState":"0",
            },
            reffields: { refpk: "cpaydeptidId", refname: "cpaydeptidName", refcode: "cpaydeptidCode" }
        },
    },    
    {
        title: "客户",
        dataIndex: "customerName",
        key:"customerId",
        // renderType: "refcomponent",
        width: 150,
        validate: false,
        filedProps: {
            childType: "retailOrderItems",
            title: "客户",
            constparam:{
                "AUTH_refdim": "customer", 
                "AUTH_refcod": "ExpenseClaim",
                "EQ_isFrozen": "0"
            },
            refName: "terminalcustomerRef",
            aliasparam: [{
                paramkey: "EQ_customerAreas.organization.id",
                alias: "organizationId",
            }],
            offersparam: {
                currentkey: ["businessName", "businessId", "businessCode","custChanTypeId","custChanTypeName","custChanTypeCode"],
                offerfields: ["dutyPersonName", "dutyPersonId", "dutyPersonCode","custchantypeId","custchantypeName","custchantypeCode"],
            },
            fieldName: "customerName",
            reffields: { refpk: "customerId", refname: "customerName", refcode: "customerCode" }
        },
    },
    {
        title: "客户渠道",
        dataIndex: "custchantypeName",
        key:"custchantypeId",
        // renderType: "refcomponent",
        width: 150,
        required:true,
        filedProps: {
            title: "客户渠道",
            refName: "custchantype",
            constparam:{
                "AUTH_refdim": "custchantype", 
                "AUTH_refcod": "ExpenseClaim",
                "EQ_enableState": "1",
            },
            fieldName: "custchantypeName",
            reffields: { refpk: "custchantypeId", refname: "custchantypeName", refcode: "custchantypeCode" }
        },
    },
    {
        title: "商品品牌",
        dataIndex: "commoditybrandName",
        key: "commoditybrandId",
        renderType: "refcomponent",
        width: 150,
        required:true,
        filedProps: {
            title: "商品品牌",
            refName: "brandref",
            constparam:{
                "AUTH_refdim": "commoditybrand", 
                "AUTH_refcod": "ExpenseClaim"
            },
            fieldName: "commoditybrandName",
            reffields: { refpk: "commoditybrandId", refname: "commoditybrandName", refcode: "commoditybrandCode" }
        },
    },
    {
        title: "商品品类",
        dataIndex: "goodscategoryName",
        key: "goodscategoryId",
        width: 150,
        required:true,
        renderType: "refcomponent",
        filedProps: {
            title: "商品品类",
            constparam:{
                "EQ_enableState": "0"
            },
            refName: "terminalGoodsCate",
            fieldName: "goodscategoryName",
            reffields: { refpk: "goodscategoryId", refname: "goodscategoryName", refcode: "goodscategoryCode" }
        },
    },
    {
        title: "责任业务",
        dataIndex: "dutyPersonName",
        key:"dutyPersonId",
        renderType: "refcomponent",
        width: 150,
        validate: false,
        required:true,
        filedProps: {
            childType: "retailOrderItems",
            title: "责任业务",
            refName: "terminalPersonRef",
            fieldName: "dutyPersonName",
            reffields: { refpk: "dutyPersonId", refname: "dutyPersonName", refcode: "dutyPersonCode" }
        },
    },
    {
        dataIndex: "year",
        title: "归属年份",
        width:100,
        render: (text, record, index) => {
            return new Date(text).getFullYear()+'-'+(new Date(text).getMonth()+1);
        },
    },
    {
        dataIndex: "notaxamount",
        key: "notaxamount",
        title: "不含税额",
        width:100,
    },
    {
        dataIndex: "companyassume",
        key: "companyassume",
        title: "公司承担金额",
        width:100,
        renderType: "inputnumber",
        edit: true,
        filedProps: {
            precision:2,
            min: 0,
        },
        required: false,
    },
    {
        dataIndex: "confirmamount",
        key: "confirmamount",
        title: "确认金额",
        width:100,
        hidepage: { 0: true },
    },
    {
        dataIndex: "remark",
        key: "remark",
        title: "备注",
        renderType: "input",
        pattern:/^\S*$/,
        patternMessage: "不能有空格",
        edit: true,
        filedProps: {
            defaultValue: "",
            maxLength: '200'
        },
        required: false,
    },
    {
        title: "付款金额",
        dataIndex: "payamount",
        key:"payamount",
        hidepage: { 0: true },
    },
    {
        title: "支付状态",
        dataIndex: "isPay",
        key:"isPay",
        hidepage: { 0: true },
    },
    {
        title: "支付时间",
        dataIndex: "payDate",
        key:"payDate",
        hidepage: { 0: true },
    },
    {
        title: "客户费用单号",
        dataIndex: "ext01",
        key:"ext01",
        hidepage: { 0: true },
    },
    {
        title: "销售发票号",
        dataIndex: "ext03",
        key:"ext03",
        hidepage: { 0: true },
    },
    {
        title: "税务云发票号",
        dataIndex: "ext04",
        key:"ext04",
        hidepage: { 0: true },
    }

]
//表单字段

export const FormField = {
    "DataHeader": {
        "title": "基础信息",
        "Field": FormDataHeader
    },
}

//表格弹框表单字段
export const FormTableField = {
}

//渲染成字表表格的头
export const childTableColumn = {
    "expenseSon": {
        "title": "明细",
        "type": "grid",
        "column": columnexpenseSon
    },
    "expenseAttachmentDtos": {
        "title": "附件",
        "type": "grid",
        "column": columnexpenseAttachmentDtos
    },
}

//渲染成字表表格的头
export const mainTableColumn = [
    {
        title: "报销单号",
        dataIndex: "billcode",
        width: 130,
        key: "billcode",
        fixed: "left",
        render: (text, record) => {
            return <a style={{ "cursor": "pointer" }}
                onClick={() => {
                    actions.routing.push(
                        {
                            pathname: 'ExpenseClaim-edit',
                            search: `?search_id=${record.id}&btnPageFlag=2`,
                        }
                    );
                    // location.reload();
                }}
            >
                {text}
            </a >;
        }
    },
    {
        title: "客户",
        dataIndex: "customerName",
        width: 140,
        key: "customerName",
        fixed: "left",
    },
    {
        title: "费用业务类型",
        dataIndex: "feeitemName",
        width: 120,
        key: "feeitemName",
        fixed: "left",
    },
    {
        title: "报销金额",
        dataIndex: "expenseamount",
        width: 100,
        key: "expenseamount",
        fixed: "left",
        sumCol:true
    },
    {
        title: "制单人",
        dataIndex: "marrkName",
        width: 100,
        key: "marrkName",
        fixed: "left",
    },
    {
        title: "单据日期",
        dataIndex: "billDate",
        width: 90,
        key: "billDate",
        render: (text) => {
            return text && ts2Formatter(text);
        }
    },
    {
        title: "审批状态",
        dataIndex: "state",
        key: "state",
        width: 90,
        render:(text, record, index)=> {
            return renderState(text);
        }
    },
    {
        title:"审核日期",
        dataIndex:"approveTime",
        key: "approveTime",
        width: 90,
        render:(text) => {
            return text && ts2Formatter(text);
        },
    },
    {
        title: "标记签收",
        dataIndex: "signReceive",
        key: "signReceive",
        width: 100,
        render:(text)=>{
            text = text===1?"已签收":"未签收";
            return text;
        }
    },
    {
        title: "商品品牌",
        dataIndex: "commoditybrandName",
        key: "commoditybrandName",
        width: 150,
    },
    {
        title: "商品品类",
        dataIndex: "goodscategoryName",
        key: "goodscategoryName",
        width: 150,
    },
    {
        title: "单据类型",
        dataIndex: "billtypeName",
        key: "billtypeName",
        width: 100,
    },
    {
        title: "部门片区",
        dataIndex: "marketareaName",
        width: 120,
        key: "marketareaName",
    },
    {
        title: "支付方式",
        dataIndex: "settlementName",
        width: 120,
        key: "settlementName",
    },
    {   
        title: "支付供应商",
        dataIndex: "paySupplerName",
        width: 100,
        key: "paySupplerName",
    },
    {   
        title: "支付客户",
        dataIndex: "payCustomerName",
        width: 100,
        key: "payCustomerName",
    },
    {   
        title: "支付个人",
        dataIndex: "payPersonName",
        width: 100,
        key: "payPersonName",
    },
    {
        title: "隶属组织",
        dataIndex: "organizationName",
        width: 150,
        key: "organizationName",
    },
    {
        title: "审批管理",
        dataIndex: "approvalName",
        width: 100,
        key: "approvalName",
    },
]

export const searchField = [
    {
        enname: "organization",
        zhname: "隶属组织",
        required: false,
        refname:"organization",
        realRef:true,
        param:{
            "AUTH_refdim": "organization", 
            "AUTH_refcod": "ExpenseConfirmation"
        },
        cascadeName: [
            {
                paramkey: "EQ_organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organization",
                offers: "marketarea",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organization",
                offers: "ext11",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organization",
                offers: "ext12",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_customerAreas.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organization",
                offers: "payCustomer",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_customerAreas.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organization",
                offers: "customer",
                resetOffersFlag: true,
            },
            {
                paramkey: "EQ_supplierFinances.organization.id",
                childtype: "DataHeader",
                refKey: "refpk",
                dtoKey: "organization",
                offers: "paySuppler",
                resetOffersFlag: true,
            }
        ],
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "billcode",
        zhname: "单据号",
        required: false,
        type: "FormControl",
        searchType:"like",
        edit: true
    },
    {
        enname: "expenseSon&confirmbillcode",
        zhname: "确认单号",
        required: false,
        type: "FormControl",
        searchType:"like",
        edit: true
    },
    {
        enname: "customer",
        zhname: "客户",
        required: false,
        realRef:true,
        alias:"organization",
        param:{
            "AUTH_refdim": "customer", 
            "AUTH_refcod": "ExpenseConfirmation"
        },
        refname:"terminalcustomerRef",
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "marrk",
        zhname: "制单人",
        required: false,
        refname:"personRef",
        realRef:true,
        param:{
            "AUTH_refdim": "marrk", 
            "AUTH_refcod": "ExpenseConfirmation"
        },
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "marrkdate",
        zhname: "订单日期",
        required: false,
        type: "RangePicker",
        rangeField: ["marrkdate", "marrkdate"],
        edit: true
    },
    {
        enname:"approveTime",
        zhname:"审核日期",
        required: false,
        type: "RangePicker",
        rangeField:["approveTime","approveTime"],
        format:"YYYY-MM-DD",
        edit: true
    },
    {
        enname: "paySuppler",
        zhname: "支付供应商",
        edit: true,
        type: "RefComponent",
        alias:"organization",
        refname: "supplierRef",
        multiple:true,
        realRef:true,
    },
    {
        enname: "payPerson",
        zhname: "支付个人",
        edit: true,
        type: "RefComponent",
        refname: "terminalPersonRef",
        multiple:true,
        realRef:true,
    },
    {   
        enname: "payCustomer",
        zhname: "支付客户",
        edit: true,
        type: "RefComponent",
        alias:"organization",
        refname: "terminalcustomerRef",
        multiple:true,
        realRef:true,
    },
    {
        enname: "custbillcode",
        zhname: "客户单号",
        required: false,
        type: "FormControl",
        searchType:"like",
        edit: true
    },
    {
        enname: "marketarea",
        zhname: "部门片区",
        required: false,
        refname:"departmentRef",
        realRef:true,
        alias:"organization",
        param:{
            "AUTH_refdim": "marketarea", 
            "AUTH_refcod": "ExpenseConfirmation"
        },
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname:"ext11",
        zhname:"部门地区",
        required: false,
        realRef:true,
        alias:"organization",
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname:"ext12",
        zhname:"部门大区",
        required: false,
        realRef:true,
        alias:"organization",
        refname:"departmentRef",
        type: "RefComponent",
        edit: true
    },
    {
        enname: "feeitem",
        zhname: "费用业务类型",
        required: false,
        refname:"feeType",
        // param:{"EQ_enableState": "1"},
        treeNodeDisabledKey:'disabledKey',
        realRef:true,
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "settlement",
        zhname: "支付方式",
        required: false,
        realRef:true,
        refname:"settlementRef",
        type: "RefComponent",
        multiple:true,
        edit: true,
    },
    {
        enname: "commoditybrand",
        zhname: "商品品牌",
        required: false,
        realRef:true,
        refname:"brandref",
        param:{
            "AUTH_refdim": "commoditybrand", 
            "AUTH_refcod": "ExpenseConfirmation"
        },
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "goodscategory",
        zhname: "商品品类",
        required: false,
        realRef:true,
        refname:"terminalGoodsCate",
        param:{
            "AUTH_refdim": "goodscategory", 
            "AUTH_refcod": "ExpenseConfirmation"
        },
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "custchantype",
        zhname: "客户渠道",
        required: false,
        refname:"custchantype",
        realRef:true,
        param:{
            "AUTH_refdim": "channelType", 
            "AUTH_refcod": "ExpenseConfirmation",
            "EQ_enableState":"2"
        },
        type: "RefComponent",
        multiple:true,
        edit: true
    },
    {
        enname: "billtype",
        zhname: "单据类型",
        code:"FA001",
        type: "Select",
        edit: true
    },
    {
        enname: "state",
        zhname: "审批状态",
        required: false,
        code:"BILL_STATUS",
        realRef:true,
        type: "Select",
        edit: true
    },
    {
        enname:"signReceive",
        zhname:"标记签收",
        required: false,
        options: [{
            "key": 1,
            "value": "已签收"
        }, {
            "key": 0,
            "value": "未签收"
        }],
        type: "Radio",
        edit: true
    },
    {
        enname:"initialStage",
        zhname:"期初标识",
        required: false,
        type: "Radio",
        options: [{
            "key": 0,
            "value": "否"
        }, {
            "key": 1,
            "value": "是"
        }],
        edit: true
    },
    {
        enname:"expenseAttachments&ext01",
        zhname:"验证发票号",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"expenseAttachments&ext02",
        zhname:"发票验证结果",
        required: false,
        searchType: 'like',
        type: "FormControl",
        edit: true
    },
    {
        enname:"ext01",
        zhname:"单据来源",
        required: false,
        options: [
            {
                name: '参照确认', code: "参照确认"
            },
            {
                name: '红冲操作', code: "红冲操作"
            },
            {
                name: '单据协同', code: "单据协同"
            },
            {
                name: '导入新增', code: "导入新增"
            },
        ],
        type: "Select",
        edit: true
    },
    {
        enname:"collect",
        zhname:"是否收藏",
        required: false,
        type: "Select",
        options: [
            {
                name: '已收藏', code: "0"
            },
            {
                name: '未收藏', code: "1"
            },
        ],
        edit: true
    },
]

export const headerButtonSets = [
    // {
    //     event: "ButtonAdd",
    //     zhname: "新增",
    //     color: 'primary',
    //     authcode: "Claimadd",
    // },
    {
        event: "ButtonSignReceive",
        zhname: "标记签收",
        authcode: "ClaimReceive",
        method: "post",
        batch:true,
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-fee/fee/expenses/updateSignReceiveInfo'
    },
]

export const columnButtonSets = {
    "delete": {
        event: "ButtonDel",
        zhname: "删除",
        batch: true,
        method: "post",
        ContentType: 'application/x-www-form-urlencoded;charset=utf-8',
        url: 'occ-fee/fee/expenses/deleteWithFriendly'
    },
    "edit": true,
    "detail": true
}

// export default {mainTableColumn,searchField,headerButtonSets,
//     columnButtonSets,childTableColumn,FormTableField,FormField}
export const SelectCode = ["SZWD","ZCLX","FA001","FA002","BILL_STATUS","QRSP001"]
